package com.terracloud.server.dao.model.sql;

import com.terracloud.server.common.data.DeviceGroupRelation;
import com.terracloud.server.common.data.TenantGroupRelation;
import com.terracloud.server.common.data.id.DeviceGroupRelationId;
import com.terracloud.server.common.data.id.TenantGroupRelationId;
import com.terracloud.server.dao.model.BaseSqlEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.UUID;

/**
 *
 * @author chenhainan
 * @since 2025/10/11
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "tenant_group_relation")
public class TenantGroupRelationEntity extends BaseSqlEntity<TenantGroupRelation> {

    @Column(name = "tenant_id")
    private UUID tenantId;

    @Column(name = "tenant_group_id")
    private UUID tenantGroupId;

    public TenantGroupRelationEntity(UUID tenantId, UUID tenantGroupId) {
        this.tenantId = tenantId;
        this.tenantGroupId = tenantGroupId;
    }

    public TenantGroupRelationEntity() {
    }

    @Override
    public TenantGroupRelation toData() {
        final var tenantGroupRelation = new TenantGroupRelation();
        tenantGroupRelation.setTenantId(tenantId);
        tenantGroupRelation.setTenantGroupId(tenantId);
        tenantGroupRelation.setId(new TenantGroupRelationId(id));
        tenantGroupRelation.setCreatedTime(createdTime);
        return tenantGroupRelation;
    }
}
